w=./build-weak/wch
# 1. start a node in solo mode
$w --port 7777 --light-exe

w=./build-weak/wch
$w --port 7778 --light-exe --consensus  Solo --Solo.node-to-connect localhost:7777


# 2.1 get node status
e=http://localhost
out=$(curl $e:7777/get_cnsss_info)
echo $out | jq .

out=$(curl $e:7777/get_node_status)
echo $out | jq .


e=http://localhost
out=$(curl $e:7778/get_cnsss_info)
echo $out | jq .

# {
#     "cnsss": "listenToOne",
#     "is_primary": true,
#     "listened_endpoint": {
#         "pk": "<mock-pk>",
#         "addr_port": "localhost:7777",
#         "cert": ""
#     },
#     "known_subs": []
# }


# --------------------------------------------------
# II. try a raft cluster
w=./build-weak/wch

# --------------------------------------------------
# 0. 🦜 : Let's start a three-node mock-exe
./build-weak/wch --port 7777 --mock-exe \
                 --consensus Raft --Raft.node-list localhost:7778 localhost:7779

./build-weak/wch --port 7778 --mock-exe \
                 --consensus Raft --Raft.node-list localhost:7777 localhost:7779

./build-weak/wch --port 7779 --mock-exe \
                 --consensus Raft --Raft.node-list localhost:7777 localhost:7778

e=http://localhost
out=$(curl $e:7777/get_cnsss_info)
echo $out | jq .

out=$(curl $e:7778/get_cnsss_info)
echo $out | jq .

out=$(curl $e:7779/get_cnsss_info)
echo $out | jq .


# --------------------------------------------------
# III. try the rbft cluster
./build-weak/wch --port 7777 --mock-exe --consensus Rbft --Bft.node-list localhost:7777 localhost:7778
./build-weak/wch --port 7778 --mock-exe --consensus Rbft --Bft.node-list localhost:7777 localhost:7778


e=http://localhost
out=$(curl $e:7777/get_cnsss_info)
echo $out | jq .

out=$(curl $e:7778/get_cnsss_info)
echo $out | jq .
